from Event import Event;

class EventDispatcher:

    def __init__(self):
        self._listeners = [];

    def addEventListener(self, name, function):
        hasListener = self.__checkListener(name, function);
        if(hasListener): return;
        listener = Listener(name,function);
        self._listeners.append(listener);

    def removeListener(self, name, function):
        print(1);

    def dispatchEvent(self, event):
        event._target = self;
        for listener in self._listeners:
            if (listener.name == event.name):
                listener.function(event);

    def __checkListener(self, name, function):
        for listener in self._listeners:
            if (listener.name == name) and (listener.function == function):
                return True;


class Listener():

    def __init__(self, name, function):
        self.name = name;
        self.function = function;